package com.example.weather.service;

import com.example.weather.dto.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class GetWeatherDataService {

    @Autowired
    private RestTemplate restTemplate;

    //调用第三方接口查询天气数据的方法

    public WeatherResponse searchWeather(String cityid){

        WeatherResponse w = null;

        w = restTemplate.getForObject("https://apis.tianapi.com/tianqi/index?" +
                    "key=58147479384231dc837ee5fd1288e6f2&city="+cityid+"&type=7",WeatherResponse.class);

        return w;
    }

}
